package com.shuan.springboothello.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置类
 *
 * @author li.peilong
 * @date 2019/01/09
 */
@Configuration
@EnableSwagger2
public class Swagger2Configuration {
    @Bean
    public Docket zcmService() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("ZCM Dialing")
                .apiInfo(zcmServiceApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.shuan.springboothello.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo zcmServiceApiInfo() {
        return new ApiInfoBuilder()
                .title("ZCM Dialing API")
                .description("ZCM Dialing RESTful API")
                .contact(new Contact("li.peilong", "", "0027002449@ztesoft.com"))
                .version("internal")
                .build();
    }

    @Bean
    public Docket actuator() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("~Monitor(Actuator)")
                .apiInfo(actuatorApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("org.springframework.boot.actuate"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo actuatorApiInfo() {
        return new ApiInfoBuilder()
                .title("Spring Boot Actuator Endpoints API")
                .description("Spring Boot Actuator Endpoints API")
                .build();
    }

}
